package com.gitee.feizns.quickstart.web.ex;

import com.gitee.feizns.quickstart.web.ex.impl.HttpExceptionHandler;
import org.springframework.http.HttpStatus;

/**
 * HTTP表面该异常是HTTP异常，
 * 一般用于配置响应HTTP状态码
 * @see HttpExceptionHandler
 * @author feizns
 * @since 2019/7/4
 */
public class HttpException extends RuntimeException {

    /**
     * HTTP状态响应码
     */
    private final HttpStatus status;

    /**
     * 自定义错误码
     */
    private ErrorCode errorCode;

    public HttpException(HttpStatus status) {
        this.status = status;
    }

    public HttpException(HttpStatus status, String message) {
        super(message);
        this.status = status;
    }

    public HttpException(HttpStatus status, ErrorCode errorCode) {
        this.status = status;
        this.errorCode = errorCode;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }

}
